package com.cwvs.cat;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;

import com.cwvs.cat.fragment.InviteClubFragment;
import com.cwvs.cat.fragment.InviteFriendFragment;

public class ClubDetailMyPubActiveInviteActivity extends FragmentActivity {

	private ImageView img_select_friend,img_select_club;
	public static String org_id = "";
	public static String act_id="";
	private ImageView header_leftImg;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_club_detail_publishactive_invite);
		Intent intent = getIntent();
		org_id = intent.getStringExtra("org_id");
		act_id = intent.getStringExtra("act_id");
		initView();
	}

	private void initView(){
		img_select_friend=(ImageView) this.findViewById(R.id.img_select_friend);
		img_select_friend.setOnClickListener(myFriendOnClickListener);
		img_select_club=(ImageView) this.findViewById(R.id.img_select_club);
		img_select_club.setOnClickListener(clubOnClickListener);
		header_leftImg = (ImageView) findViewById(R.id.header_leftImg);
		header_leftImg.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		img_select_friend.performClick();
	}


	private OnClickListener myFriendOnClickListener=new OnClickListener() {
		@Override
		public void onClick(View v) {
			clearSelection();
			img_select_friend.setImageResource(R.drawable.myfriend_blue);
			img_select_friend.setEnabled(false);
			FragmentManager fm=getSupportFragmentManager();
			FragmentTransaction ft=fm.beginTransaction();
			InviteFriendFragment friendFatherFragment=new InviteFriendFragment();
			ft.replace(R.id.linear_invate_contact, friendFatherFragment,MainActivity.TAG);
			ft.commit();

		}
	};

	private OnClickListener clubOnClickListener=new OnClickListener() {
		@Override
		public void onClick(View v) {
			clearSelection();
			img_select_club.setImageResource(R.drawable.club_blue);
			img_select_club.setEnabled(false);
			FragmentManager fm=getSupportFragmentManager();
			FragmentTransaction ft=fm.beginTransaction();
			InviteClubFragment inviteClubFragment=new InviteClubFragment();
			ft.replace(R.id.linear_invate_contact, inviteClubFragment,MainActivity.TAG);
			ft.commit();

		}
	};

	private void clearSelection() {
		img_select_friend.setImageResource(R.drawable.myfriend_white);
		img_select_friend.setEnabled(true);
		img_select_club.setImageResource(R.drawable.club_white);
		img_select_club.setEnabled(true);

	}

}
